import requestConfig from '@/utils/config/index.js'

function requestFun(param) {
	return new Promise( (resolve,reject)=>{
		uni.request({
			url: param.url,
			method: param.method,
			data: param.data,
			header: {
				'X-Authorization-access_token': uni.getStorageSync("_app_token")
			},
			success: (res) => {
				resolve(res.data)
			},
			fail: (res) => {
				reject(res)
			}
		})
	})
	
}

// 扫描二维码
export function scanQr(data) {
	let param = {
		data : data,
		method: "GET" ,
		url :  requestConfig.baseUrl + '/inspection/v3/api/app_xundianjian/scanQr', 
	}
	return requestFun(param) 
}

// 查询巡检总结页面的统计数量
export function getTaskStat(data) {
	let param = {
		data : data,
		method: "GET" ,
		url :  requestConfig.baseUrl + '/inspection/v3/api/app_xundianjian/getTaskStatForHn', 
	}
	return requestFun(param) 
}

// 保存巡检总结
export function saveFinishReport(data) {
	let param = {
		data : data,
		method: "post" ,
		url :  requestConfig.baseUrl + '/inspection/v3/api/app_xundianjian/saveFinishReport', 
	}
	return requestFun(param) 
}

// 查询巡检任务的区域或设备列表
export function taskPageTypeList(data) {
	let param = {
		data : data,
		method: "POST" ,
		url :  requestConfig.baseUrl + '/inspection/v3/api/app_xundianjian/taskPageTypeList', 
	}
	return requestFun(param) 
}

// 放弃巡检任务
export function giveUpTask(data) {
	let param = {
		data : data,
		method: "GET" ,
		url :  requestConfig.baseUrl + '/inspection/v3/api/app_xundianjian/giveUpTask', 
	}
	return requestFun(param) 
}

// 根据路线ID获得路线信息
export function getLineInfo(data) {
	let param = {
		data : data,
		method: "GET" ,
		url :  requestConfig.baseUrl + '/inspection/v3/api/app_xundianjian/getLineInfo', 
	}
	return requestFun(param) 
}

// 检查项历史值
export function getInspectionHistoryInfo(data) {
	let param = {
		data : data,
		method: "GET" ,
		url :  requestConfig.baseUrl + '/inspection/v3/api/app_xundianjian/getInspectionHistoryForHn', 
	}
	return requestFun(param) 
}

// 获取巡点检计划信息
export function getTaskPlanInfo(id) {
	let param = {
		data : { id },
		method: "GET" ,
		url :  requestConfig.baseUrl + '/inspection/v3/api/taskPlan/queryById', 
	}
	return requestFun(param) 
}

// 根据任务ID和区域ID获取任务检查项列表
export function getTaskInspectionList(data) {
	let param = {
		data : data,
		method: "GET" ,
		url :  requestConfig.baseUrl + '/inspection/v3/api/app_xundianjian/getTaskInspectionList', 
	}
	return requestFun(param) 
}

// 保存检查项列表数据
export function saveTaskInspectionListForHn(data) {
	let param = {
		data : data,
		method: "POST" ,
		url :  requestConfig.baseUrl + '/inspection/v3/api/app_xundianjian/saveTaskInspectionListForHn', 
	}
	return requestFun(param) 
}

// 领取任务
export function getGateTask(data) {
	let param = {
		data : data,
		method: "GET" ,
		url :  requestConfig.baseUrl + '/inspection/v3/api/app_xundianjian/getGateTask', 
	}
	return requestFun(param) 
}

// 根据当前用户查询路线列表
export function getLineList(data) {
	let param = {
		data : data,
		method: "GET" ,
		url :  requestConfig.baseUrl + '/inspection/v3/api/app_xundianjian/getLineList', 
	}
	return requestFun(param) 
}

// 根据当前用户查询查询任务执行人列表
export function getExecutorList(data) {
	let param = {
		data : data,
		method: "GET" ,
		url :  requestConfig.baseUrl + '/inspection/v3/api/app_xundianjian/getExecutorList', 
	}
	return requestFun(param) 
}

// 查询巡点检任务
export function taskPageList(data) {
	let param = {
		data : data,
		method: "POST" ,
		url :  requestConfig.baseUrl + '/inspection/v3/api/app_xundianjian/taskPageList', 
	}
	return requestFun(param) 
}

// 任务检查项-保存任务检查项的缺陷编号
export function saveTaskInspDfNo(data) {
	let param = {
		data : data,
		method: "GET" ,
		url :  requestConfig.baseUrl + '/inspection/v3/api/taskInspection/saveTaskInspDfNo', 
	}
	return requestFun(param)
}

// 任务检查项-保存任务检查项
export function saveOneTaskInspec(data) {
	let param = {
		data : data,
		method: "POST" ,
		url :  requestConfig.baseUrl + '/inspection/v3/api/taskInspection/saveOneTaskInspec', 
	}
	return requestFun(param) 
}

// 获得设备运行状态集合
export function getEquipmentRunState(data) {
	let param = {
		data : data,
		method: "GET" ,
		url :  requestConfig.baseUrl + '/inspection/v3/api/app_xundianjian/getEquipmentRunState', 
	}
	return requestFun(param) 
}

// 数据字典类型-通过类型编码查询字典类型
export function queryByCatNo(data) {
	let param = {
		data : data,
		method: "GET" ,
		url :  requestConfig.baseUrl + '/inspection/v3/api/inspCodeCategory/queryByCatNo', 
	}
	return requestFun(param) 
}

// 离线巡检下载任务
export function downloadTask(data) {
	let param = {
		data : data,
		method: "GET" ,
		url :  requestConfig.baseUrl + '/inspection/v3/api/app_xundianjian/downloadTask', 
	}
	return requestFun(param) 
}

// 离线巡检上传任务
export function uploadTask(data) {
	let param = {
		data : data,
		method: "POST" ,
		url :  requestConfig.baseUrl + '/inspection/v3/api/app_xundianjian/uploadTask',
	}
	return requestFun(param) 
}

// 测点数据保存
export function saveMpData(data) {
	let param = {
		data : data,
		method: "POST" ,
		url :  requestConfig.baseUrl + '/inspection/v3/api/inspMp/saveMpData', 
	}
	return requestFun(param) 
}

// 测点列表数据
export function selectMpData(data) {
	let param = {
		data : data,
		method: "POST" ,
		url :  requestConfig.baseUrl + '/inspection/v3/api/inspMp/selectMpData', 
	}
	return requestFun(param) 
}

// 首页-巡检统计
export function getMyTask(data) {
	let param = {
		data : data,
		method: "GET" ,
		url :  requestConfig.baseUrl + '/inspection/v3/api/xdjindex/getMyTask', 
	}
	return requestFun(param) 
}

// 查询任务申请免检情况
export function getExemptionInsp(data) {
	let param = {
		data : data,
		method: "GET" ,
		url :  requestConfig.baseUrl + '/inspection/v3/api/riTaskInfo/getExemptionInsp', 
	}
	return requestFun(param) 
}

// 设备采集状况登记
export function logCollectStatus(data) {
	let param = {
		data : data,
		method: "POST" ,
		url :  requestConfig.baseUrl + '/inspection/v3/api/app_xundianjian/logCollectStatus', 
	}
	return requestFun(param) 
}

// 设备采集状况批量登记
export function logCollectStatusBatch(data) {
	let param = {
		data : data,
		method: "POST" ,
		url :  requestConfig.baseUrl + '/inspection/v3/api/app_xundianjian/logCollectStatusBatch', 
	}
	return requestFun(param) 
}

// --------------------------------------巡检（新）--------------------------------------------------

// 放弃巡检任务
export function giveUpInspTask(data) {
	let param = {
		data : data,
		method: "GET" ,
		url :  requestConfig.baseUrl + '/inspection/v3/api/app_xundianjian/giveUpInspTask', 
	}
	return requestFun(param) 
}

// 根据任务ID和区域或设备ID获取任务检查项列表
export function getTaskImplementInfo(data) {
	let param = {
		data : data,
		method: "GET" ,
		url :  requestConfig.baseUrl + '/inspection/v3/api/app_xundianjian/getTaskImplementInfo', 
	}
	return requestFun(param) 
}

// 根据路线检查项ID获取测点列表
export function selectMpByLineInspId(data) {
	let param = {
		data : data,
		method: "GET" ,
		url :  requestConfig.baseUrl + '/inspection/v3/api/lineInspMp/selectByLineInspIdIo', 
	}
	return requestFun(param) 
}

// 新增测点
export function saveTaskInspMp(data) {
	let param = {
		data : data,
		method: "POST" ,
		url :  requestConfig.baseUrl + '/inspection/v3/api/taskInspMp/saveBatch', 
	}
	return requestFun(param) 
}

// 删除测点
export function delTaskInspMp(data) {
	let param = {
		data : data,
		method: "GET" ,
		url :  requestConfig.baseUrl + '/inspection/v3/api/taskInspMp/delete', 
	}
	return requestFun(param) 
}

// 获取巡点检任务信息
export function getTaskInfo(riTaskId) {
	let param = {
		data : { riTaskId },
		method: "GET" ,
		url :  requestConfig.baseUrl + '/inspection/v3/api/riTask/queryById', 
	}
	return requestFun(param) 
}

// 查询巡检任务的区域或设备列表
export function taskTypeList(data) {
	let param = {
		data : data,
		method: "POST" ,
		url :  requestConfig.baseUrl + '/inspection/v3/api/app_xundianjian/taskTypeList', 
	}
	return requestFun(param) 
}

// 任务检查项-保存任务检查项
export function saveTaskInspection(data) {
	let param = {
		data : data,
		method: "POST" ,
		url :  requestConfig.baseUrl + '/inspection/v3/api/taskInspection/saveTaskInspection', 
	}
	return requestFun(param) 
}

// 保存检查项列表数据
export function saveTaskInspectionBatch(data) {
	let param = {
		data : data,
		method: "POST" ,
		url :  requestConfig.baseUrl + '/inspection/v3/api/app_xundianjian/saveTaskInspectionBatch', 
	}
	return requestFun(param) 
}

// 查询巡检总结页面的统计数量
export function getTaskSummaryStat(data) {
	let param = {
		data : data,
		method: "GET" ,
		url :  requestConfig.baseUrl + '/inspection/v3/api/app_xundianjian/getTaskSummaryStat', 
	}
	return requestFun(param) 
}